package com.bjsc.controller.data;

import com.baomidou.mybatisplus.plugins.Page;
import com.bjsc.common.controller.SuperController;
import com.bjsc.service.IDataService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import java.util.Map;

/**
 * @author create by VIC.Huang
 * @date 2018/2/7
 */
@Controller
@RequestMapping("/data")
public class DataController extends SuperController {
    @Autowired
    private IDataService dataService;

    @RequestMapping("/betRecord/list/{pageNumber}")
    public String betList(@PathVariable Integer pageNumber, @RequestParam(defaultValue = "10") Integer pageSize, Model model) {
        Page<Map<Object, Object>> page = getPage(pageNumber, pageSize);
        model.addAttribute("pageSize", pageSize);
        Page<Map<Object, Object>> pageData = dataService.selectBetRecordPage(page);
        model.addAttribute("pageData", pageData);
        return "data/betRecordList";
    }

    @RequestMapping("/openRecord/list/{pageNumber}")
    public String openList(@PathVariable Integer pageNumber, @RequestParam(defaultValue = "10") Integer pageSize, Model model) {
        Page<Map<Object, Object>> page = getPage(pageNumber, pageSize);
        model.addAttribute("pageSize", pageSize);
        Page<Map<Object, Object>> pageData = dataService.selectOpenRecordPage(page);
        model.addAttribute("pageData", pageData);
        return "data/openRecordList";
    }
}
